//@author A0085897A

import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

// Test suite for the wrapString() method in the Print class
@RunWith(Parameterized.class)
public class PrintWrapStringTest {

	// Arguments for wrapString()
	private String _inputStr;
	private int _inputWidth;
	
	// Expected result of wrapString()
	private List<String> _expectedResult;

	public PrintWrapStringTest(String str, int width, List<String> expectedOutput) {
		this._inputStr = str;
		this._inputWidth = width;
		this._expectedResult = expectedOutput;
	}
	
	@Parameters
	public static Collection<Object[]> data() {
		Object[][] data = new Object[][] {
			// String _inputStr, int _inputWidth, List<String> _expectedResult
			{ "ABC", 1, Arrays.asList(new String[]{"A", "B", "C"}) },
			{ "ABC", 2, Arrays.asList(new String[]{"AB", "C"}) },
			{ "An extremely long String", 5, Arrays.asList(new String[]{"An ex", "treme", "ly", "long", "Strin", "g"}) },
			{ "An extremely long String", 9, Arrays.asList(new String[]{"An", "extremely", "long", "String"}) },
			{ "Anextremelylongstring", 4, Arrays.asList(new String[]{"Anex", "trem", "elyl", "ongs", "trin", "g", }) },
			{ "Anextremelylongstring", 1, Arrays.asList(new String[]{"A", "n", "e", "x", "t", "r", "e", "m", "e", "l", "y", "l", "o", "n", "g", "s", "t", "r", "i", "n", "g"}) },
			{ "0 123 45 678 9", 2, Arrays.asList(new String[]{"0", "12", "3", "45", "67", "8", "9"}) },
			{ "0 123 45 678 9", 3, Arrays.asList(new String[]{"0", "123", "45", "678", "9"}) },
			{ "0 1 2 3 4 5 6 7 8 9", 2, Arrays.asList(new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}) },
			{ "0 1 2 3 4 5 6 7 8 9", 4, Arrays.asList(new String[]{"0 1", "2 3", "4 5", "6 7", "8 9"}) },
		};
		return Arrays.asList(data);
	}

	@Test
	public void test() {
		Print print = new Print();
	    assertEquals(print.wrapString(this._inputStr, this._inputWidth), this._expectedResult);
	}

}
